#
# define a macro to build an executable
#
macro(build_exec name)

  # define executable name
  if (Kokkos_ENABLE_CUDA)
    set(EXE_NAME "${name}.cuda")
  elseif(Kokkos_ENABLE_OPENMP)
    set(EXE_NAME "${name}.openmp")
  elseif(Kokkos_ENABLE_HIP)
    set(EXE_NAME "${name}.hip")
  else()
    set(EXE_NAME "${name}.serial")
  endif()
  
  # define list of source files
  set (EXE_NAME_SRC
    ${name}.cpp
    )

  # define how to build and link
  add_executable(${EXE_NAME}
    ${EXE_NAME_SRC})
  
  target_link_libraries(${EXE_NAME} PUBLIC kokkos)
  target_link_libraries(${EXE_NAME} PUBLIC kokkoskernels)

  if (Kokkos_ENABLE_HWLOC)
    target_link_libraries(${EXE_NAME} PUBLIC hwloc)
  endif()
  
endmacro(build_exec)

####################################################
build_exec(gmres)
